package com.cyandpos.pad.utils.log;

import com.google.gson.Gson;

/**
 * Created by zx on 2018/7/5.
 */

public class NetWorkWriteThread extends Thread {
    public static boolean isWriteThreadLive=false;//写日志线程是否已经在运行了

    public NetWorkWriteThread() {
        isWriteThreadLive=true;
    }

    @Override
    public void run() {
        isWriteThreadLive=true;
        Gson gson=new Gson();
        while(!NetWorkLog.tempQueue.isEmpty()){//对列不空时
            try {
                //写日志到SD卡
                NetWorkLog.recordStringLog(gson.toJson(NetWorkLog.tempQueue.poll()));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        isWriteThreadLive=false;//队列中的日志都写完了，关闭线程（也可以常开 要测试下）
    }



}
